package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TFieldvalueCgzx;
import com.ruoyi.system.service.ITFieldvalueCgzxService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 外购件扩展字段 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/tFieldvalueCgzx")
public class TFieldvalueCgzxController extends BaseController
{
    private String prefix = "system/tFieldvalueCgzx";
	
	@Autowired
	private ITFieldvalueCgzxService tFieldvalueCgzxService;
	
	@RequiresPermissions("system:tFieldvalueCgzx:view")
	@GetMapping()
	public String tFieldvalueCgzx()
	{
	    return prefix + "/tFieldvalueCgzx";
	}
	
	/**
	 * 查询外购件扩展字段列表
	 */
	@RequiresPermissions("system:tFieldvalueCgzx:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TFieldvalueCgzx tFieldvalueCgzx)
	{
		startPage();
        List<TFieldvalueCgzx> list = tFieldvalueCgzxService.selectTFieldvalueCgzxList(tFieldvalueCgzx);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出外购件扩展字段列表
	 */
	@RequiresPermissions("system:tFieldvalueCgzx:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TFieldvalueCgzx tFieldvalueCgzx)
    {
    	List<TFieldvalueCgzx> list = tFieldvalueCgzxService.selectTFieldvalueCgzxList(tFieldvalueCgzx);
        ExcelUtil<TFieldvalueCgzx> util = new ExcelUtil<TFieldvalueCgzx>(TFieldvalueCgzx.class);
        return util.exportExcel(list, "tFieldvalueCgzx");
    }
	
	/**
	 * 新增外购件扩展字段
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存外购件扩展字段
	 */
	@RequiresPermissions("system:tFieldvalueCgzx:add")
	@Log(title = "外购件扩展字段", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TFieldvalueCgzx tFieldvalueCgzx)
	{		
		return toAjax(tFieldvalueCgzxService.insertTFieldvalueCgzx(tFieldvalueCgzx));
	}

	/**
	 * 修改外购件扩展字段
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		TFieldvalueCgzx tFieldvalueCgzx = tFieldvalueCgzxService.selectTFieldvalueCgzxById(id);
		mmap.put("tFieldvalueCgzx", tFieldvalueCgzx);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存外购件扩展字段
	 */
	@RequiresPermissions("system:tFieldvalueCgzx:edit")
	@Log(title = "外购件扩展字段", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TFieldvalueCgzx tFieldvalueCgzx)
	{		
		return toAjax(tFieldvalueCgzxService.updateTFieldvalueCgzx(tFieldvalueCgzx));
	}
	
	/**
	 * 删除外购件扩展字段
	 */
	@RequiresPermissions("system:tFieldvalueCgzx:remove")
	@Log(title = "外购件扩展字段", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tFieldvalueCgzxService.deleteTFieldvalueCgzxByIds(ids));
	}
	
}
